import { View } from "../../../../../mvc/core/View";
import { ObjCreate } from "../../../common/ObjCreate";
import { TigerMachineColumn } from "./TigerMachineColumn";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { TigerMachineItem } from "./TigerMachineItem";
import { CutDataUtil } from "../../../../../common/tools/CutDataUtil";
import { Cache } from "../../../../cache/Cache";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
type int = number;
//class TigerMachine
    
    export  class TigerMachine extends View
    {
        constructor()
        {
            super();
            this._columnsArr = new Array<any>();
            this._resultArr = [];
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            var loc2=null;
            this._bg = ObjCreate.createBitmap("", 0, 0, this);
            var loc1=0;
            while (loc1 < 4) 
            {
                loc2 = new TigerMachineColumn(15, 1 + loc1);
                loc2.x = 92 * loc1 + 23;
                loc2.y = 15;
                addChild(loc2);
                this._columnsArr.push(loc2);
                ++loc1;
            }
            LoaderHelp.addResCallBack(ResFileConst.fashionFlyWing, this.onLoadBmResource);
            return;
        }

        public showResult(arg1: Array<any>): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=0;
            var loc5=0;
            if (arg1.length > 0) 
            {
                loc4 = 0;
                while (loc4 < 4) 
                {
                    loc3 = arg1[loc4];
                    this._initShowArr.push(loc3);
                    loc1 = this._columnsArr[loc4];
                    loc2 = new TigerMachineItem();
                    loc2.setData(loc3);
                    loc1.setInitItem(loc2);
                    ++loc4;
                }
            }
            else 
            {
                this._initShowArr = [];
                loc5 = 0;
                while (loc5 < 4) 
                {
                    loc3 = CutDataUtil.getRandomNum(Cache.instance.wardrobe.FlyWingAttArr);
                    this._initShowArr.push(loc3);
                    loc1 = this._columnsArr[loc5];
                    loc2 = new TigerMachineItem();
                    loc2.setData(loc3);
                    loc1.setInitItem(loc2);
                    ++loc5;
                }
            }
            return;
        }

        public start(arg1: Array<any>): void
        {
            var loc1=null;
            var loc3=null;
            var loc4=null;
            this._resultArr = arg1;
            var loc2=0;
            while (loc2 < this._columnsArr.length) 
            {
                loc1 = this._columnsArr[loc2] as TigerMachineColumn;
                (loc3 = new TigerMachineItem()).setData(this._initShowArr[loc2]);
                (loc4 = new TigerMachineItem()).setData(this._resultArr[loc2]);
                loc1.start(loc3, loc4);
                ++loc2;
            }
            this._initShowArr = this._resultArr;
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.FBFlyGrowTigerBg);
            return;
        }

        public shineResult(arg1: Boolean): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._columnsArr.length) 
            {
                if (this.columnShine(loc2)) 
                {
                    loc1 = this._columnsArr[loc2] as TigerMachineColumn;
                    loc1.shineResult(arg1);
                }
                ++loc2;
            }
            return;
        }

        /* internal  */columnShine(arg1: int): Boolean
        {
            var loc2=0;
            var loc3=0;
            var loc4=0;
            var loc1=Cache.instance.wardrobe.flyWingTigerResultArr;
            loc2 = loc1[arg1];
            loc4 = 0;
            var loc5=0;
            while (loc5 < loc1.length) 
            {
                loc3 = loc1[loc5];
                if (loc2 == loc3) 
                {
                    ++loc4;
                }
                ++loc5;
            }
            if (loc4 >= 2) 
            {
                return true;
            }
            return false;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isRolling: Boolean=false;

        /* internal */ /* var */_columnsArr: Array<any>;

        /* internal */ /* var */_initShowArr: Array<any>=null;

        /* internal */ /* var */_resultArr: Array<any>;
    }
